﻿using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using BGM.Domain.DTO;


namespace BloodGlucoseManagerApplication
{
    /// <summary>
    /// Interaction logic for SelectPatientWindow.xaml
    /// </summary>
    public partial class SelectPatientWindow : Window
    {
        private Controller controller;
        public SelectPatientWindow(Controller controller)
        {
            this.controller = controller;
            InitializeComponent();


            MemoryStream iconStream = new MemoryStream();
            global::BloodGlucoseManagerApplication.Properties.Resources.SelectPatient.Save(iconStream);
            iconStream.Seek(0, SeekOrigin.Begin);
            this.Icon = BitmapFrame.Create(iconStream);

            patientList.ItemsSource = controller.GetAllPatients();

        }

        private void patientList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            controller.SelectedPatient = (Patient)patientList.SelectedItem;
        }

        private void patientList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            DialogResult = true;
        }
    }
}
